# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

PortGroup           muniversal 1.0
PortGroup           cmake 1.1
PortGroup           xcode_workaround 1.0

# https://trac.macports.org/ticket/59875
PortGroup           legacysupport 1.0

legacysupport.newest_darwin_requires_legacy 9

name                x265
version             3.2.1
revision            1

checksums           rmd160  7386c00a49a2fc143cd3c8cea657872235a8ba77 \
                    sha256  fb9badcf92364fd3567f8b5aa0e5e952aeea7a39a2b864387cec31e3b58cbbcc \
                    size    1426255

categories          multimedia
platforms           darwin
license             GPL-2+
maintainers         nomaintainer

description         H.265 encoder
long_description    x265 is a free software library and application for \
                    encoding video streams into the H.265/MPEG-H HEVC \
                    compression format, and is released under the terms of the \
                    GNU GPL.
homepage            https://www.videolan.org/developers/x265.html
master_sites        https://download.videolan.org/pub/videolan/x265/
distname            ${name}_${version}
worksrcdir          ${distname}/source

depends_build-append \
                    port:gmake \
                    port:nasm

compiler.blacklist-append *llvm-gcc-4.2

# https://trac.macports.org/ticket/59246
xcode_workaround.fixed_xcode_version 11.2

configure.env-append CONFIGURE=${configure.cmd} BUILD=${build.cmd}
build.env-append     BUILD=${build.cmd}
destroot.env-append  BUILD=${build.cmd} ARCH=none
configure.cmd        ${portpath}/${filesdir}/configure.sh
build.cmd            ${portpath}/${filesdir}/build.sh

#    error: illegal text-relocation to '_x265_pw_1'
#   report: https://mailman.videolan.org/pipermail/x265-devel/2014-May/004476.html
# solution: http://lists.apple.com/archives/unix-porting/2008/Jan/msg00027.html
if {[variant_exists universal] && [variant_isset universal]} {
    lappend merger_configure_ldflags(i386) -Wl,-read_only_relocs,suppress
    foreach arch ${configure.universal_archs} {
        lappend merger_configure_env(${arch}) ARCH=${arch}
        lappend merger_build_env(${arch}) ARCH=${arch}
    }
} else {
    if {${build_arch} eq "i386"} {
        configure.ldflags-append -Wl,-read_only_relocs,suppress
    }
    configure.env-append ARCH='${build_arch}'
    build.env-append ARCH='${build_arch}'
}

livecheck.regex     "${name}_(\\d+(?:\\.\\d+)*)${extract.suffix}"
